package com.igor.reporting.pages.issue;

import java.util.List;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.igor.reporting.dao.issue.IssueDAO;
import com.igor.reporting.entities.issue.Issue;

public class Browse {

	@Inject
	private IssueDAO issueDAO;
	@Property
	private List<Issue> issues;
	@Property
	private Issue issue;

	@InjectPage
	private Edit edit;

	
	void onActivate() {
		issues = issueDAO.findAll();
	}

	
	@OnEvent(component="edit")
	Object onEdit(Long id){
		edit.setId(id);
		return edit;
	}
	
	@OnEvent(component="delete")
	Object onDelete(Long id){
		Issue i = issueDAO.find(id);
		issueDAO.delete(i);
		return null;
	}
}
